<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 30612
  Date: 2023/4/10
  Time: 11:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/js/jquery-3.6.1.js"></script>
</head>
<body>
<table>

    <thead>
    <tr>
        <th>编号</th>
        <th>名称</th>
        <th>作者</th>
    </tr>
    </thead>

    <tbody id="book">

    </tbody>

</table>

</body>

<script>

    $.get('http://localhost:8080/all',function (res) {

        console.log(res);
        var str;

        //转成JSON
        var json=JSON.parse(res)

        console.log(JSON.parse(res));

        $.each(json , function (index,item) {

            str +="<tr>" +
                "<td>"+item.id+"</td>" +
                "<td>"+item.name+"</td>" +
                "<td>"+item.author+"</td>" +
                "</tr>"

        })


        console.log(str);

        $("#book").empty().append(str)

    })

</script>

</html>
